package com.gzg.userservice.handler;
import com.gzg.userservice.Exception.MyException;
import com.gzg.userservice.domain.vo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器，处理项目中抛出的业务异常
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 捕获业务异常
     * @param ex
     * @return
     */
    @ExceptionHandler
    public Result exceptionHandler(MyException ex){
        //TODO 发送异常信息到日志服务
        return Result.fail(ex.getMessage());
    }

}
